<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="bjui-pageContent">
	<c:if test="${empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/foods/insert.do" data-toggle="validate" data-reload-navtab="true">
	</c:if>
	<c:if test="${not empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/foods/update.do" data-toggle="validate" data-reload-navtab="true">
		<input type="hidden" name="id" value="${info.id}">
	</c:if>
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                	<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">商品分类：</label>
	                        <select name="goods.id" data-toggle="selectpicker" data-width="200" id="goodtype">
	                        	<option>请选择</option>
	                        	<c:forEach items="${glist}" var="list">
	                        	<option <c:if test="${list.id == info.goods.id}">selected="selected"</c:if> value="${list.id}">${list.name}</option>	
	                        	</c:forEach>
	                        </select>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">头像：</label>
	                        <div style="display:inline-block; vertical-align:middle;">
							    <div id="icon_pic_up" data-toggle="upload" data-uploader="<%=request.getContextPath()%>/tea/foods/springUpload.do"
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="icon_upload_success"
							        data-icon="cloud-upload">
						        </div>
						        <input type="hidden" name="icon" value="${info.icon}" id="icon_pic">
							</div>
							<span id="icon_span_pic">
								<c:if test="${not empty info.icon}">
								已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/${info.icon}">
								</c:if>
							</span>
                    	</td>
		    		</tr>
		    		<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">名称：</label>
	                        <input type="text" name="name" value="${info.name}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">原价：</label>
	                        <input type="text" name="oldPrice" value="${info.oldPrice}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">特价：</label>
	                        <input type="text" name="price" value="${info.price}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">描述：</label>
	                        <input type="text" name="description" value="${info.description}" size="60">
	                    </td>
		    		</tr>
					<tr>
                   		<td colspan="2">
	                        <label class="control-label x100">配图：</label>
	                        <div style="display:inline-block; vertical-align:middle;">
							    <div id="image_pic_up" data-toggle="upload" data-uploader="<%=request.getContextPath()%>/tea/foods/springUpload.do"
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="image_upload_success"
							        data-icon="cloud-upload">
						        </div>
						        <input type="hidden" name="image" value="${info.image}" id="image_pic">
							</div>
							<span id="image_span_pic">
								<c:if test="${not empty info.image}">
								已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/${info.image}">
								</c:if>
							</span>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">等级：</label>
	                        <input type="text" name="rating" value="${info.rating}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">销售数量：</label>
	                        <input type="text" name="sellCount" value="${info.sellCount}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">信息：</label>
	                        <input type="text" name="info" value="${info.info}" size="60">
	                    </td>
		    		</tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>
<script type="text/javascript">
	function icon_upload_success(file, data) {
	    var json = $.parseJSON(data);
	    $(this).bjuiajax('ajaxDone', json);
	    if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
	        $('#icon_pic').val(json.filename);
	        $('#icon_span_pic').html('已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/'+json.filename +'">');
	    }
	}
    function image_upload_success(file, data) {
        var json = $.parseJSON(data);
        $(this).bjuiajax('ajaxDone', json);
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#image_pic').val(json.filename);
            $('#image_span_pic').html('已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/'+json.filename +'">');
        }
    }
</script>